* RESULTS:
* 1) ERRORS:
* - Estonia 1992, 1994, Hungary 1989, Finland 1944 should probably be dropped from the analysis (if they are part of it)

* 2) PROBLEMATIC CASES:
* - Greece 2011: two elections in same year
* - cases to think about: Germany 1982 (maybe Belgium 1967 and 2009)

* Italy: not problematic as the relevant cells (pm_vote_share; pm_vote_share_d1;
* pm_vote_share_l1; cum_pm_duration) are left blank for period after 1991



* AUSTRIA
* Austria 1970/03/01 (cabinet start date: 1945/12/04)
assert float(round(pm_vote_share, .1))    == float(44.7) if country_name == "Austria" & year == 1969
//assert float(round(pm_vote_share_d1, .1)) == float(-3.7) if country_name == "Austria" & year == 1969
//assert float(round(pm_vote_share_l1, .1)) == float(48.4) if country_name == "Austria" & year == 1969
assert float(round(cum_pm_duration, .01)) == float(24.25) if country_name == "Austria" & year == 1969

* Austria 1999/10/03 (cabinet start date: 1970/04/21)
assert float(round(pm_vote_share, .1))    == float(33.2) if country_name == "Austria" & year == 1999
assert float(round(pm_vote_share_d1, .1)) == float(-4.9) if country_name == "Austria" & year == 1999
assert float(round(pm_vote_share_l1, .1)) == float(38.1) if country_name == "Austria" & year == 1999
assert float(round(cum_pm_duration, .01)) == float(29.47) if country_name == "Austria" & year == 1999



* BELGIUM
* Belgium 1968/06/17:
* Observation for this election was correctly dropped from dataset as PSC-CVP changed into CVP (and PSC);
* BUT: It is worth considering whether to count CVP as a continuation of the previous government (both parties continue to exist, Euskens was PM for PSC-CVP before); see also election 2009 below

* Belgium 1974/03/10 (cabinet start date: 1973/01/26)
assert float(round(pm_vote_share, .1))    == float(26.7) if country_name == "Belgium" & year == 1973
assert float(round(pm_vote_share_d1, .1)) == float(-0.5) if country_name == "Belgium" & year == 1973
assert float(round(pm_vote_share_l1, .1)) == float(27.2) if country_name == "Begium" & year == 1973
assert float(round(cum_pm_duration, .01)) == float(1.12) if country_name == "Belgium" & year == 1973

* Belgium 1978/12/17 (cabinet start date: 1974/04/25)
assert float(round(pm_vote_share, .1))    == float(26.1) if country_name == "Belgium" & year == 1978
assert float(round(pm_vote_share_d1, .1)) == float(-0.1) if country_name == "Belgium" & year == 1978
assert float(round(pm_vote_share_l1, .1)) == float(26.2) if country_name == "Begium" & year == 1978
assert float(round(cum_pm_duration, .01)) == float(4.65) if country_name == "Belgium" & year == 1978

* Belgium 2007/06/10 (cabinet start date: 1999/07/12)
assert float(round(pm_vote_share, .1))    == float(11.8) if country_name == "Belgium" & year == 2006
assert float(round(pm_vote_share_d1, .1)) == float(-3.5) if country_name == "Belgium" & year == 2006
assert float(round(pm_vote_share_l1, .1)) == float(15.4) if country_name == "Begium" & year == 2006
assert float(round(cum_pm_duration, .01)) == float(7.92) if country_name == "Belgium" & year == 2006

* Belgium 2010/06/13 (cabinet start date: 2008/12/30)
* Correctly dropped because CD&V was in a list as CD&V/N-VA in previous election



* DENMARK
* Denmark 1998/03/11 (cabinet start date: 1993/01/25)
assert float(round(pm_vote_share, .1))    == float(35.9) if country_name == "Denmark" & year == 1997
assert float(round(pm_vote_share_d1, .1)) == float(1.3)  if country_name == "Denmark" & year == 1997
assert float(round(pm_vote_share_l1, .1)) == float(34.6) if country_name == "Denmark" & year == 1997
assert float(round(cum_pm_duration, .01)) == float(5.13) if country_name == "Denmark" & year == 1997



* FINLAND
* Finland 1945/03/18 (cabinet start date: 1944/09/21)
* THEORETICALLY THERE SHOULD BE NO OBSERVATION FOR THIS YEAR!
* But even using Kok-party as incumbent before election, STATA produces error messages for some of the commands
* assert float(round(pm_vote_share, .1))    == 15.0 if country_name == "Finland" & year == 1944
* assert float(round(pm_vote_share_d1, .1)) == 1.4 if country_name == "Finland" & year == 1944
* assert float(round(pm_vote_share_l1, .1)) == 13.6 if country_name == "Finland" & year == 1944
* assert float(round(cum_pm_duration, .01)) == 0.49 if country_name == "Finland" & year == 1944

* Finland 1958/07/07 (cabinet start date: 1957/05/27)
assert float(round(pm_vote_share, .1))    == float(23.1) if country_name == "Finland" & year == 1958
assert float(round(pm_vote_share_d1, .1)) == float(-1.0) if country_name == "Finland" & year == 1958
assert float(round(pm_vote_share_l1, .1)) == float(24.1) if country_name == "Finland" & year == 1958
assert float(round(cum_pm_duration, .01)) == float(1.11) if country_name == "Finland" & year == 1958



* GERMANY
* Germany 1987/01/25 (cabinet start date: 1982/10/01)
assert float(round(pm_vote_share, .1))    == float(34.5) if country_name == "Germany" & year == 1986
assert float(round(pm_vote_share_d1, .1)) == float(-3.7) if country_name == "Germany" & year == 1986
assert float(round(pm_vote_share_l1, .1)) == float(38.2) if country_name == "Germany" & year == 1986
assert float(round(cum_pm_duration, .01)) == float(4.32) if country_name == "Germany" & year == 1986

* Germany 2005/09/18 (cabinet start date: 1998/10/27)
assert float(round(pm_vote_share, .1))    == float(34.2) if country_name == "Germany" & year == 2005
assert float(round(pm_vote_share_d1, .1)) == float(-4.3) if country_name == "Germany" & year == 2005
assert float(round(pm_vote_share_l1, .1)) == float(38.5) if country_name == "Germany" & year == 2005
assert float(round(cum_pm_duration, .01)) == float(6.90) if country_name == "Germany" & year == 2005



* GREECE
* IMPORTANT: There are TWO elections in 2011.
* (You might have mentioned that the second elections will be dropped in such a case, but I am not sure.)
* FIRST ELECTION: Greece 2012/05/06 (cabinet start date: 2009/10/06)
assert float(round(pm_vote_share, .1))    == float(13.2) if country_name == "Greece" & year == 2011
assert float(round(pm_vote_share_d1, .1)) == float(-30.7) if country_name == "Greece" & year == 2011
assert float(round(pm_vote_share_l1, .1)) == float(43.9) if country_name == "Greece" & year == 2011
assert float(round(cum_pm_duration, .01)) == float(2.58) if country_name == "Greece" & year == 2011
* SECOND ELECTION: Greece 2012/06/17 (cabinet start date: 2009/10/06)
* - NOT INCLUDED IN DATASET!!! -
assert float(round(pm_vote_share, .1))    == float(12.3) if country_name == "Greece" & year == 2011
assert float(round(pm_vote_share_d1, .1)) == float(-0.9) if country_name == "Greece" & year == 2011
assert float(round(pm_vote_share_l1, .1)) == float(13.2) if country_name == "Greece" & year == 2011
assert float(round(cum_pm_duration, .01)) == float(2.7) if country_name == "Greece" & year == 2011



* ITALY
* BEFORE 1992: I can see nothing the STATA code would have trouble with; the CBEV dataset looks okay to me
* AFTER 1992 Italy gets messy: the old party system breaks down, new parties come up and change their names; for elections from 1994 to 2001 (= 3 elections) we lack information about vote share of individual parties (electoral alliances)
* i.e. we DO NOT know the vote share and CANNOT calculate first differences for this period
* In the CBEV dataset the corresponding cells are left blank "." (not for cabinet duration, though!?)



* NETHERLANDS
* Netherlands 1959/03/12 (cabinet start date: 1948/08/07)
assert float(round(pm_vote_share, .1))    == float(30.4) if country_name == "Netherlands" & year == 1958
assert float(round(pm_vote_share_d1, .1)) == float(-2.3) if country_name == "Netherlands" & year == 1958
assert float(round(pm_vote_share_l1, .1)) == float(32.7) if country_name == "Netherlands" & year == 1958
assert float(round(cum_pm_duration, .01)) == float(10.6) if country_name == "Netherlands" & year == 1958

* Netherlands 1967/02/15 (cabinet start date: 1959/05/19)
assert float(round(pm_vote_share, .1))    == float(26.5) if country_name == "Netherlands" & year == 1966
assert float(round(pm_vote_share_d1, .1)) == float(-5.4) if country_name == "Netherlands" & year == 1966
assert float(round(pm_vote_share_l1, .1)) == float(31.9) if country_name == "Netherlands" & year == 1966
assert float(round(cum_pm_duration, .01)) == float(7.75) if country_name == "Netherlands" & year == 1966



*NORWAY
* Norway 1973/09/09 (cabinet start date: 1971/03/17)
assert float(round(pm_vote_share, .1))    == float(35.3) if country_name == "Norway" & year == 1973
assert float(round(pm_vote_share_d1, .1)) == float(-11.2) if country_name == "Norway" & year == 1973
assert float(round(pm_vote_share_l1, .1)) == float(46.5) if country_name == "Norway" & year == 1973
assert float(round(cum_pm_duration, .01)) == float(2.48) if country_name == "Norway" & year == 1973



* POLAND
* Poland 1993/09/19 (cabinet start date: 1992/07/11)
assert float(round(pm_vote_share, .1))    == float(10.6) if country_name == "Poland" & year == 1993
assert float(round(pm_vote_share_d1, .1)) == float(-1.7) if country_name == "Poland" & year == 1993
assert float(round(pm_vote_share_l1, .1)) == float(12.3) if country_name == "Poland" & year == 1993
assert float(round(cum_pm_duration, .01)) == float(1.19) if country_name == "Poland" & year == 1993



* PORTUGAL
* Portugal 1979/10/05 (cabinet start date: 1976/07/23)
assert float(round(pm_vote_share, .1))    == float(27.3) if country_name == "Portugal" & year == 1979
assert float(round(pm_vote_share_d1, .1)) == float(-7.6) if country_name == "Portugal" & year == 1979
assert float(round(pm_vote_share_l1, .1)) == float(34.9) if country_name == "Portugal" & year == 1979
assert float(round(cum_pm_duration, .01)) == float(3.2) if country_name == "Portugal" & year == 1979



* SWEDEN
* Sweden 1979/09/16 (cabinet start date: 1978/10/13)
assert float(round(pm_vote_share, .1))    == float(10.6) if country_name == "Sweden" & year == 1979
assert float(round(pm_vote_share_d1, .1)) == float(-0.5) if country_name == "Sweden" & year == 1979
assert float(round(pm_vote_share_l1, .1)) == float(11.1) if country_name == "Sweden" & year == 1979
assert float(round(cum_pm_duration, .01)) == float(0.93) if country_name == "Sweden" & year == 1979



* USA
* USA 1980/11/04 (president in office: 1977/01/20)
assert float(round(pm_vote_share, .1))    == float(44.7) if country_name == "United States" & year == 1980
assert float(round(pm_vote_share_d1, .1)) == float(-6.4) if country_name == "United States" & year == 1980
assert float(round(pm_vote_share_l1, .1)) == float(51.0) if country_name == "United States" & year == 1980
assert float(round(cum_pm_duration, .01)) == float(3.79) if country_name == "United States" & year == 1980



* UK
* UK 1974/02/28 (cabinet start date: 1970/06/19)
assert float(round(pm_vote_share, .1))    == float(38.0)  if country_name == "United Kingdom" & year == 1973
assert float(round(pm_vote_share_d1, .1)) == float(-8.4)  if country_name == "United Kingdom" & year == 1973
assert float(round(pm_vote_share_l1, .1)) == float(46.4)  if country_name == "United Kingdom" & year == 1973
assert float(round(cum_pm_duration, .01)) == float(3.70)  if country_name == "United Kingdom" & year == 1973

* UK 1974/10/10 (cabinet start date: 1974/03/04)
assert float(round(pm_vote_share, .1))    == float(39.2)  if country_name == "United Kingdom" & year == 1974
assert float(round(pm_vote_share_d1, .1)) == float(2.0)   if country_name == "United Kingdom" & year == 1974
assert float(round(pm_vote_share_l1, .1)) == float(37.2)  if country_name == "United Kingdom" & year == 1974
assert float(round(cum_pm_duration, .01)) == float(0.60)  if country_name == "United Kingdom" & year == 1974

* UK 1997/05/01 (cabinet start date: 1979/05/04)
assert float(round(pm_vote_share, .1))    == float(30.7)  if country_name == "United Kingdom" & year == 1996
assert float(round(pm_vote_share_d1, .1)) == float(-11.2) if country_name == "United Kingdom" & year == 1996
assert float(round(pm_vote_share_l1, .1)) == float(41.9)  if country_name == "United Kingdom" & year == 1996
assert float(round(cum_pm_duration, .01)) == float(18.01)  if country_name == "United Kingdom" & year == 1996
